- Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathStringDemo.java
32 lines (23 loc) Β· 706 Bytes
/
StringDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
packagesection5_Strings;
publicclassStringDemo {
publicstaticvoidmain(String[] args) {
Strings = "hello";
s = "bye";
System.out.println(s); // bye
Strings2 = "hello";
Strings3 = "hello";
System.out.println(s2+ "," + s3);
s3 = "sleep";
System.out.println(s2+ "," + s3);
System.out.println(s3.charAt(0));
System.out.println(s3.charAt(1));
System.out.println(s3.charAt(2));
System.out.println(s3.charAt(3));
System.out.println(s3.charAt(s3.length() - 1));
System.out.println(s3.length());
System.out.println(s2.substring(0));
System.out.println(s2.substring(1, 3));
System.out.println(s2.substring(3, 3));
System.out.println(s2.substring(3));
}
}